<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <ui:composition template="/master.xhtml">


        <ui:define name="menu">
            <ui:include src="../menu.xhtml" /> 
        </ui:define>

        <ui:define name="TituloModulo">
            Gestão de Utilizadores
        </ui:define>

        <ui:define name="TituloConteudoPrincipal">
            Registar Utilizador
        </ui:define>

        <ui:define name="ConteudoPrincipal">
            <p:messages globalOnly="true"/>
            <h:form>
                <h:panelGrid columns="3">

                    <h:outputLabel value="#{bundle01.nomeUsuario}" for="nomeUsuario" />
                    <p:inputText id="nomeUsuario" value="#{loginUsuarioController.selected.nomeUsuario}" title="#{bundle01.nomeUsuario}" required="true" requiredMessage="#{bundle01.obrigatorio}"/>
                    <p:message for="nomeUsuario"/>

                    <h:outputLabel value="#{bundle01.senha}" for="senha" />
                    <p:password id="senha" match="senha2" inline="true" validatorMessage="Senha Não Conscide" minLength="5" feedback="true" value="#{loginUsuarioController.selected.senha}" title="#{bundle01.senha}" required="true"  requiredMessage="#{bundle01.obrigatorio}" />
                    <p:message for="senha"/>

                    <h:outputLabel value="#{bundle01.senha2}" for="senha" />
                    <p:password id="senha2" feedback="false"  minLength="5" title="#{bundle01.senha2}" required="true" value="#{loginUsuarioController.selected.senha}" requiredMessage="#{bundle01.obrigatorio}"/>
                    <p:message for="senha2" />

                    <h:outputLabel value="#{bundle01.tipoUsuario}" for="tipoUsuario" />

                    <p:selectOneMenu id="tipoUsuario"  value="#{loginUsuarioController.selected.fkTipoUsuario}">
                        <f:selectItems value="#{tipoUsuarioController.itemsAvailableSelectOne}"/>
                    </p:selectOneMenu>
                    <h:outputLabel/>


                    <h:outputLabel value="Associar ao Funcionario" for="funcionario" />
                    <p:selectOneMenu id="funcionario"  value="#{loginUsuarioController.funcionario}">
                        <f:selectItems value="#{funcionarioController.itemsAvailableSelectOne}"/>
                    </p:selectOneMenu>
                    <h:outputLabel/>

                </h:panelGrid>

                <p:commandButton ajax="false"  actionListener="#{loginUsuarioController.gravar(login.loginUsuario,funcionarioController)}" icon="ui-icon-disk" value="#{bundle01.salvar}" />

                &nbsp;

                <p:commandButton ajax="false"  action="#{loginUsuarioController.prepareList}" value="#{bundle01.listar}" immediate="true"/>

            </h:form>

        </ui:define>
    </ui:composition>

</html>
